﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    internal class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("请输入数字的个数:");

            int n = int.Parse(Console.ReadLine());
            int[] array = new int[n];
            Console.WriteLine("请输入数字,以空格分开:");
            //将输入的一行字符串以空格分开，存到数组array1中
            string s = Console.ReadLine();
            string[] array1 = s.Split('\u0020');
            //将字符串数组转为整型数组
            for (int i = 0; i < n; i++)
            {
                array[i] = int.Parse(array1[i]);
            }
            //求最大值，最小值，平均值，和
            int max = array[0];
            int min = array[0];
            float average = 0f;
            int sum = 0;
            for (int i = 0; i < n; i++)
            {
                if (array[i] > max)
                    max = array[i];
                if (array[i] < min)
                    min = array[i];
                sum += array[i];
            }
            average = ((float)sum) / n;
            Console.WriteLine("最大值为:" + max);
            Console.WriteLine("最小值为:" + min);
            Console.WriteLine("平均值为:" + average);
            Console.WriteLine("和为:" + sum);
        }
    }
}
